//
//  FirstViewController.m
//  BaseApp
//
//  Created by Yunuo on 16/9/14.
//  Copyright © 2016年 Romens. All rights reserved.
//

#import "FirstViewController.h"
//#import "Common.h"
#import "CollectionViewController.h"
#import "MapViewController.h"

@interface FirstViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *_listTableView;
    NSMutableArray *_rootDataArray;
    
    //跳转控制器
    CollectionViewController *CollectionVC;
    MapViewController *mapVC;
}
@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"First";
    
    [self initTableView];
    
    [self TBdata];
    
    
    
}

- (void)initTableView {
    _listTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [self.view addSubview:_listTableView];
    
    _listTableView.dataSource = self;
    _listTableView.delegate = self;
    
}
- (void)TBdata {
    if (!_rootDataArray) {
        _rootDataArray = [[NSMutableArray alloc] initWithObjects:@"cellctionView",@"map",@"UILabel属性设置", nil];
    }
}
#pragma mark - UITableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"fist_cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"first_cell"];
    }
    if (_rootDataArray.count <= indexPath.row) {
        cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
    }else {
        cell.textLabel.text = [_rootDataArray objectAtIndex:indexPath.row];
    }
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    //几种跳转方式
    
    if (indexPath.row == 0) {
        CollectionVC = [[CollectionViewController alloc] init];
        [self.navigationController pushViewController:CollectionVC animated:YES];
    }else if (indexPath.row == 1) {
        mapVC = [[MapViewController alloc] init];
        UINavigationController *naviC2 = [[UINavigationController alloc] initWithRootViewController:mapVC];
        [self presentViewController:naviC2 animated:YES completion:^{
        }];
    }else if (indexPath.row == 2) {
        
    }else if (indexPath.row == 3) {
        
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
